package com.example;

import java.util.concurrent.Executor;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.web.servlet.ServletComponentScan;
import org.springframework.scheduling.annotation.AsyncConfigurerSupport;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;

@SpringBootApplication
@ServletComponentScan
@EnableAsync
public class SpringBootNutzApplication extends AsyncConfigurerSupport implements CommandLineRunner {
	
	private static Logger logger = LoggerFactory.getLogger(SpringBootNutzApplication.class);

	public static void main(String[] args) {
		SpringApplication.run(SpringBootNutzApplication.class, args);
	}
	
	@Override
    public Executor getAsyncExecutor() {
        ThreadPoolTaskExecutor executor = new ThreadPoolTaskExecutor();
        executor.setCorePoolSize(2);
        executor.setMaxPoolSize(2);
        executor.setQueueCapacity(500);
        executor.setThreadNamePrefix("GithubLookup-");
        executor.initialize();
        return executor;
    }

	@Override
	public void run(String... arg0) throws Exception {
		logger.info("应用启动完成");
	}
}
